/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package presentation.view;


import presentation.controller.ControlFrameAñadirProfesor;
import vo.ProfesorVO;

/**
 *
 * @author Joanna 8a
 */
public class FrameAñadirProfesor extends javax.swing.JFrame {

    /**
     * Creates new form FrameAñadirProfesor
     */
    public FrameAñadirProfesor() {
        initComponents();
        jSpinnerReputacionPr.setModel(new javax.swing.SpinnerNumberModel(0, 0, 5, 1));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabelReputacion = new javax.swing.JLabel();
        jTextField_Correo = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jButtonAñadir = new javax.swing.JButton();
        jLabelNombresProfesor = new javax.swing.JLabel();
        jLabel2ApellidosProfesor = new javax.swing.JLabel();
        jTextFieldNombresProfesor = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jTextFieldApellidosProfesor = new javax.swing.JTextField();
        jSpinnerReputacionPr = new javax.swing.JSpinner();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Añadir Profesor");

        jLabelReputacion.setFont(new java.awt.Font("Segoe UI Light", 0, 14)); // NOI18N
        jLabelReputacion.setText("Reputación");

        jTextField_Correo.setFont(new java.awt.Font("Segoe UI Light", 0, 14)); // NOI18N

        jLabel4.setFont(new java.awt.Font("Segoe UI Light", 0, 14)); // NOI18N
        jLabel4.setText("Correo electrónico");

        jButtonAñadir.setFont(new java.awt.Font("Segoe UI Light", 0, 14)); // NOI18N
        jButtonAñadir.setText("Añadir");
        jButtonAñadir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAñadirActionPerformed(evt);
            }
        });

        jLabelNombresProfesor.setFont(new java.awt.Font("Segoe UI Light", 0, 14)); // NOI18N
        jLabelNombresProfesor.setText("Nombres");

        jLabel2ApellidosProfesor.setFont(new java.awt.Font("Segoe UI Light", 0, 14)); // NOI18N
        jLabel2ApellidosProfesor.setText("Apellidos");

        jTextFieldNombresProfesor.setFont(new java.awt.Font("Segoe UI Light", 0, 14)); // NOI18N

        jButton3.setFont(new java.awt.Font("Segoe UI Light", 0, 14)); // NOI18N
        jButton3.setText("Volver");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jTextFieldApellidosProfesor.setFont(new java.awt.Font("Segoe UI Light", 0, 14)); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonAñadir)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabelNombresProfesor)
                        .addComponent(jLabel2ApellidosProfesor)
                        .addComponent(jLabelReputacion)
                        .addComponent(jLabel4)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(117, 117, 117)
                        .addComponent(jButton3)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextFieldNombresProfesor)
                            .addComponent(jTextFieldApellidosProfesor)
                            .addComponent(jTextField_Correo, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jSpinnerReputacionPr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelNombresProfesor)
                    .addComponent(jTextFieldNombresProfesor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2ApellidosProfesor)
                    .addComponent(jTextFieldApellidosProfesor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelReputacion)
                    .addComponent(jSpinnerReputacionPr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextField_Correo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonAñadir)
                    .addComponent(jButton3))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonAñadirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAñadirActionPerformed
        ProfesorVO vo = new ProfesorVO();
        vo.setNombre(jTextFieldNombresProfesor.getText());
        vo.setApellido(jTextFieldApellidosProfesor.getText());
        vo.setReputacion((int)jSpinnerReputacionPr.getValue());
        vo.setCorreo(jTextField_Correo.getText());
        
        String mg = new ControlFrameAñadirProfesor().crearProfesor(vo);
        
        this.setVisible(false);
        
        
    }//GEN-LAST:event_jButtonAñadirActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_jButton3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameAñadirProfesor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameAñadirProfesor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameAñadirProfesor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameAñadirProfesor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrameAñadirProfesor().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButtonAñadir;
    private javax.swing.JLabel jLabel2ApellidosProfesor;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabelNombresProfesor;
    private javax.swing.JLabel jLabelReputacion;
    private javax.swing.JSpinner jSpinnerReputacionPr;
    private javax.swing.JTextField jTextFieldApellidosProfesor;
    private javax.swing.JTextField jTextFieldNombresProfesor;
    private javax.swing.JTextField jTextField_Correo;
    // End of variables declaration//GEN-END:variables
}
